<%--
  Created by IntelliJ IDEA.
  User: KK
  Date: 2022/10/15
  Time: 10:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="head.jsp"%>
<html>
<head>
    <title>Title</title>
</head>
<body>
<div class="container">
    <div class="row">
        <h2>欢迎您：${is_login.name}</h2><a href="/stu/logout">注销</a>
        <div class="col-md-6 col-md-offset-3">
            <button type="button" class="btn btn-success" onclick="addStu()">新增</button>
            <table class="table table-striped">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>姓名</th>
                    <th>年龄</th>
                    <th>密码</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <c:if test="${stus==null}">
                    <h3>暂无数据，请稍后再试！</h3>
                </c:if>
                <c:forEach items="${stus}" var="stus">
                    <tr>
                        <td>${stus.id}</td>
                        <td><a href="/book/getUserBook?id="+${stus.id}>${stus.name}</a></td>
                        <td>${stus.age}</td>
                        <td>${stus.password}</td>
                        <td>
                            <button type="button" class="btn btn-danger" onclick="delStu(${stus.id})">删除</button>
                            <button type="button" class="btn btn-warning">修改</button>
                        </td>
                    </tr>
                </c:forEach>
                <tr>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
<script>
    function addStu() {
        location.assign("/addStu.jsp");
    }
    function delStu(id) {
        if (confirm("是否确认删除")) {
            location.assign("/stu/delStu?id="+id);
        }
    }
</script>
</body>
</html>
